<template>
    <view class="container">
        <form @submit="bindSave" report-submit>
            <view class="register" @tap="goregister">企业入驻</view>

            <view class="login">企业登录</view>

            <view class="inputlist">
                <view class="inputitem">
                    <view><image src="/static/imgs/icon/username.png"></image></view>
                    <view><input value="" type="text" name="name" placeholder="请输入账号" placeholder-style="font-size:14px;" /></view>
                </view>

                <view class="inputitem">
                    <view><image src="/static/imgs/icon/pwd.png"></image></view>
                    <view><input value="" type="password" name="password" placeholder="请输入密码" placeholder-style="font-size:14px;" /></view>
                </view>
                <!-- <view class="forget" bindtap="toCompanyforget">忘记密码？</view> -->
                <view class="button"><button formType="submit">登录</button></view>
            </view>
        </form>
    </view>
</template>

<script>
import { Company } from '../../model/company-model.js';
var company = new Company();
export default {
    data() {
        return {};
    }
    /**
     * 生命周期函数--监听页面加载
     */,
    onLoad: function (options) {
        uni.setNavigationBarTitle({
            title: '企业登录'
        });
    },
    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {},
    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {},
    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {},
    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {},
    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {},
    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {},
    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {},
    methods: {
        bindSave: function (e) {
            console.log(e.detail.formId);
            var that = this;
            var name = e.detail.value.name;
            var password = e.detail.value.password;
            if (name == '') {
                uni.showModal({
                    title: '提示',
                    content: '请填写企业登录账号',
                    showCancel: false
                });
                return;
            }
            if (password == '') {
                uni.showModal({
                    title: '提示',
                    content: '请填写企业登录密码',
                    showCancel: false
                });
                return;
            }
            var params = {
                name: name,
                password: password
            };
            company.Login((data) => {
                if (data.error == 0) {
                    // wx.setStorageSync('companyid', data.companyid);

                    uni.setStorageSync('ctoken', data.ctoken);
                    uni.redirectTo({
                        url: '/pages/companycenter/index'
                    });
                } else {
                    uni.showModal({
                        title: '提示',
                        content: data.msg,
                        showCancel: false
                    });
                    return;
                }
            }, params);
        },

        goregister: function (e) {
            uni.navigateTo({
                url: '/pages/companyregister/index'
            });
        }
    }
};
</script>
<style>
.container {
    background-color: #fff;
    min-height: 100%;
    display: flex;
    flex-direction: column;
}

.register {
    width: 700rpx;
    padding-top: 60rpx;
    padding-bottom: 30rpx;
    text-align: right;
    margin-right: 50rpx;
    color: #07b56d;
    font-size: 14px;
}

.login {
    width: 700rpx;
    font-size: 24px;
    font-weight: 600;
    margin-left: 30rpx;
}

.inputlist {
    display: flex;
    flex-direction: column;

    padding: 50rpx;
}

.inputitem {
    display: flex;
    flex-direction: row;
    border-bottom: 1rpx solid #f5f5f5;
    padding-bottom: 30rpx;
}
.inputitem view:nth-child(1) {
    height: 80rpx;
    display: flex;
    justify-content: center;
    align-items: center;
}
.inputitem image {
    width: 40rpx;
    height: 40rpx;
}

.inputitem input {
    width: 500rpx;
    height: 80rpx;
    margin-left: 30rpx;
}

.button {
    margin-top: 30rpx;
}

.button button {
    background: #07b56d;
    border-radius: 15rpx;
    color: #fff;
    font-size: 14px;
    height: 100rpx;
    line-height: 100rpx;
}
button::after {
    border: 0rpx;
}

.forget {
    color: #5693fc;
    font-size: 0.7rem;
    width: 700rpx;
    text-align: right;
}
</style>
